/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import java.awt.*;
import javax.swing.*;

/**
 *
 * @author Tom Gurung
 */
public class UppersAndDowners extends JPanel {
    
    int[] x = new int[10];
    int[] y = new int[10];
    int[] x2 = new int[10];
    int[] y2 = new int[10];
  
    public UppersAndDowners (int[] upX, int[] upY, int[] downX, int[] downY) {
        
        this.setOpaque(false);
        for (int i = 0; i < 10; i++) {
            x[i] = upX[i];
            y[i] = upY[i];
            x2[i] = downX[i];
            y2[i] = downY[i];
        }
    }
    
    @Override
    public void paintComponent(Graphics g)
    {

        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        for (int i = 0; i < 10; i = i+2) {

            g2.drawLine(x[i],y[i],x[i+1],y[i+1]);

            double frac = 0.03;
            int deltaX = x[i+1] - x[i];
            int deltaY = y[i+1] - y[i];

            g2.drawLine(x[i+1], y[i+1],(x[i] + (int)((1-frac)*deltaX + frac*deltaY)),(y[i] + (int)((1-frac)*deltaY - frac*deltaX)));

            g2.drawLine(x[i] + (int)((1-frac)*deltaX - frac*deltaY),y[i] + (int)((1-frac)*deltaY + frac*deltaX),x[i+1], y[i+1]);
            
           

        }

        for (int i = 0; i < 10; i = i+2) {
            

            g2.drawLine(x2[i],y2[i],x2[i+1],y2[i+1]);

            double frac = 0.03;
            int deltaX = x2[i+1] - x2[i];
            int deltaY = y2[i+1] - y2[i];

            g2.drawLine(x2[i+1], y2[i+1],(x2[i] + (int)((1-frac)*deltaX + frac*deltaY)),(y2[i] + (int)((1-frac)*deltaY - frac*deltaX)));

            g2.drawLine(x2[i] + (int)((1-frac)*deltaX - frac*deltaY),y2[i] + (int)((1-frac)*deltaY + frac*deltaX),x2[i+1], y2[i+1]);

        }

    }
    
}
